<!DOCTYPE html>
<html lang="en-US">
  <head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width,initial-scale=1">
    <title>HBase介绍 | flybird&#39;s blog</title>
    <meta name="generator" content="VuePress 1.8.0">
    <link rel="icon" href="https://infinitypro-img.infinitynewtab.com/custom-icon/8001de1jd3n68lbfnxxt564xvb0vl5.png?imageMogr2/thumbnail/240x/format/webp/blur/1x0/quality/100|imageslim">
    <script language="javascript" type="text/javascript" src="https://cdn.staticfile.org/jquery/1.7.2/jquery.min.js"></script>
    <script language="javascript" type="text/javascript" src="/js/MouseClickEffect.js"></script>
    <meta name="description" content="Stay hungry, Stay foolish">
    <meta name="viewport" content="width=device-width,initial-scale=1,user-scalable=no">
    
    <link rel="preload" href="/assets/css/0.styles.324c77a5.css" as="style"><link rel="preload" href="/assets/js/app.55c4f7c3.js" as="script"><link rel="preload" href="/assets/js/5.86109dd2.js" as="script"><link rel="preload" href="/assets/js/1.74974061.js" as="script"><link rel="preload" href="/assets/js/2.ab8aa845.js" as="script"><link rel="preload" href="/assets/js/49.feee5279.js" as="script"><link rel="preload" href="/assets/js/18.cfe435f1.js" as="script"><link rel="prefetch" href="/assets/js/10.1f3187f9.js"><link rel="prefetch" href="/assets/js/11.67fe3d1f.js"><link rel="prefetch" href="/assets/js/12.0052f325.js"><link rel="prefetch" href="/assets/js/13.bad60b36.js"><link rel="prefetch" href="/assets/js/14.6a893378.js"><link rel="prefetch" href="/assets/js/15.899648d3.js"><link rel="prefetch" href="/assets/js/16.0575f88b.js"><link rel="prefetch" href="/assets/js/17.86f820d7.js"><link rel="prefetch" href="/assets/js/19.1d1c7b67.js"><link rel="prefetch" href="/assets/js/20.218819f6.js"><link rel="prefetch" href="/assets/js/21.223949af.js"><link rel="prefetch" href="/assets/js/22.eb6ea80c.js"><link rel="prefetch" href="/assets/js/23.cf07ba0c.js"><link rel="prefetch" href="/assets/js/24.eeb9d511.js"><link rel="prefetch" href="/assets/js/25.4be64ae7.js"><link rel="prefetch" href="/assets/js/26.6aea0ced.js"><link rel="prefetch" href="/assets/js/27.7540f161.js"><link rel="prefetch" href="/assets/js/28.d88a26e6.js"><link rel="prefetch" href="/assets/js/29.7edc404c.js"><link rel="prefetch" href="/assets/js/30.b3c16bef.js"><link rel="prefetch" href="/assets/js/31.63392d40.js"><link rel="prefetch" href="/assets/js/32.b90695c8.js"><link rel="prefetch" href="/assets/js/33.669186a5.js"><link rel="prefetch" href="/assets/js/34.57a9b7fc.js"><link rel="prefetch" href="/assets/js/35.81d5b8b3.js"><link rel="prefetch" href="/assets/js/36.466fde53.js"><link rel="prefetch" href="/assets/js/37.ff7b9321.js"><link rel="prefetch" href="/assets/js/38.132de18a.js"><link rel="prefetch" href="/assets/js/39.80a51963.js"><link rel="prefetch" href="/assets/js/40.e7d6c67d.js"><link rel="prefetch" href="/assets/js/41.d195ea4b.js"><link rel="prefetch" href="/assets/js/42.dbe1a8f1.js"><link rel="prefetch" href="/assets/js/43.2ea02aec.js"><link rel="prefetch" href="/assets/js/44.294015bc.js"><link rel="prefetch" href="/assets/js/45.3cf9c326.js"><link rel="prefetch" href="/assets/js/46.8cc95701.js"><link rel="prefetch" href="/assets/js/47.ddf6cc44.js"><link rel="prefetch" href="/assets/js/48.ba718ca6.js"><link rel="prefetch" href="/assets/js/50.6f2d0d0d.js"><link rel="prefetch" href="/assets/js/51.ebe1eb07.js"><link rel="prefetch" href="/assets/js/52.3e47f7ae.js"><link rel="prefetch" href="/assets/js/53.861fb703.js"><link rel="prefetch" href="/assets/js/54.f7d3a937.js"><link rel="prefetch" href="/assets/js/55.d90baa98.js"><link rel="prefetch" href="/assets/js/56.ba7f3256.js"><link rel="prefetch" href="/assets/js/57.90441d7f.js"><link rel="prefetch" href="/assets/js/58.a0d58abc.js"><link rel="prefetch" href="/assets/js/59.7f649313.js"><link rel="prefetch" href="/assets/js/6.00dfc51e.js"><link rel="prefetch" href="/assets/js/60.60dd83d2.js"><link rel="prefetch" href="/assets/js/61.b84cd1ef.js"><link rel="prefetch" href="/assets/js/62.8ed6541f.js"><link rel="prefetch" href="/assets/js/63.84bfbbbf.js"><link rel="prefetch" href="/assets/js/64.01c483db.js"><link rel="prefetch" href="/assets/js/65.278ce63e.js"><link rel="prefetch" href="/assets/js/66.cb493053.js"><link rel="prefetch" href="/assets/js/67.8c2201b6.js"><link rel="prefetch" href="/assets/js/68.46467c87.js"><link rel="prefetch" href="/assets/js/69.ee34297d.js"><link rel="prefetch" href="/assets/js/7.aaee1baa.js"><link rel="prefetch" href="/assets/js/70.3a016bcf.js"><link rel="prefetch" href="/assets/js/71.1cb787d0.js"><link rel="prefetch" href="/assets/js/72.2ee0677e.js"><link rel="prefetch" href="/assets/js/73.3e1e1729.js"><link rel="prefetch" href="/assets/js/74.947d7cd3.js"><link rel="prefetch" href="/assets/js/75.2e5c7344.js"><link rel="prefetch" href="/assets/js/76.6c098cc2.js"><link rel="prefetch" href="/assets/js/77.03fd3a89.js"><link rel="prefetch" href="/assets/js/78.38d2d963.js"><link rel="prefetch" href="/assets/js/79.ea508df9.js"><link rel="prefetch" href="/assets/js/8.35d0b089.js"><link rel="prefetch" href="/assets/js/80.b2b1dda3.js"><link rel="prefetch" href="/assets/js/81.d7db5a4d.js"><link rel="prefetch" href="/assets/js/82.1c148069.js"><link rel="prefetch" href="/assets/js/83.51e2c0d0.js"><link rel="prefetch" href="/assets/js/84.6118b266.js"><link rel="prefetch" href="/assets/js/85.55a516f8.js"><link rel="prefetch" href="/assets/js/86.3b73f7a9.js"><link rel="prefetch" href="/assets/js/87.123149cb.js"><link rel="prefetch" href="/assets/js/88.f87dde9d.js"><link rel="prefetch" href="/assets/js/89.06c3b9a1.js"><link rel="prefetch" href="/assets/js/9.58e6c220.js"><link rel="prefetch" href="/assets/js/vendors~flowchart.080f3458.js">
    <link rel="stylesheet" href="/assets/css/0.styles.324c77a5.css">
  </head>
  <body>
    <div id="app" data-server-rendered="true"><div><div class="theme-container" data-v-0b87bb44><div data-v-0b87bb44><div id="loader-wrapper" class="loading-wrapper" data-v-1c4f0192 data-v-0b87bb44 data-v-0b87bb44><div class="loader-main" data-v-1c4f0192><div data-v-1c4f0192></div><div data-v-1c4f0192></div><div data-v-1c4f0192></div><div data-v-1c4f0192></div></div> <!----> <!----></div> <div class="password-shadow password-wrapper-out" style="display:none;" data-v-73c95a87 data-v-0b87bb44 data-v-0b87bb44><h3 class="title" style="display:none;" data-v-73c95a87 data-v-73c95a87>flybird's blog</h3> <!----> <label id="box" class="inputBox" style="display:none;" data-v-73c95a87 data-v-73c95a87><input type="password" value="" data-v-73c95a87> <span data-v-73c95a87>Konck! Knock!</span> <button data-v-73c95a87>OK</button></label> <div class="footer" style="display:none;" data-v-73c95a87 data-v-73c95a87><span data-v-73c95a87><i class="iconfont reco-theme" data-v-73c95a87></i> <a target="blank" href="https://vuepress-theme-reco.recoluan.com" data-v-73c95a87>vuePress-theme-reco</a></span> <span data-v-73c95a87><i class="iconfont reco-copyright" data-v-73c95a87></i> <a data-v-73c95a87><span data-v-73c95a87>flybird</span>
            
          <span data-v-73c95a87>2020 - </span>
          2021
        </a></span></div></div> <div class="hide" data-v-0b87bb44><header class="navbar" data-v-0b87bb44><div class="sidebar-button"><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" role="img" viewBox="0 0 448 512" class="icon"><path fill="currentColor" d="M436 124H12c-6.627 0-12-5.373-12-12V80c0-6.627 5.373-12 12-12h424c6.627 0 12 5.373 12 12v32c0 6.627-5.373 12-12 12zm0 160H12c-6.627 0-12-5.373-12-12v-32c0-6.627 5.373-12 12-12h424c6.627 0 12 5.373 12 12v32c0 6.627-5.373 12-12 12zm0 160H12c-6.627 0-12-5.373-12-12v-32c0-6.627 5.373-12 12-12h424c6.627 0 12 5.373 12 12v32c0 6.627-5.373 12-12 12z"></path></svg></div> <a href="/" class="home-link router-link-active"><!----> <span class="site-name">flybird's blog</span></a> <div class="links"><div class="color-picker"><a class="color-button"><i class="iconfont reco-color"></i></a> <div class="color-picker-menu" style="display:none;"><div class="mode-options"><h4 class="title">Choose mode</h4> <ul class="color-mode-options"><li class="dark">dark</li><li class="auto active">auto</li><li class="light">light</li></ul></div></div></div> <div class="search-box"><input aria-label="Search" autocomplete="off" spellcheck="false" value=""> <!----></div> <nav class="nav-links can-hide"><div class="nav-item"><a href="/index.html" class="nav-link"><i class="iconfont reco-home"></i>
  主页
</a></div><div class="nav-item"><div class="dropdown-wrapper"><a class="dropdown-title"><span class="title"><i class="iconfont reco-category"></i>
      分类
    </span> <span class="arrow right"></span></a> <ul class="nav-dropdown" style="display:none;"><li class="dropdown-item"><!----> <a href="/categories/大数据/" class="nav-link"><i class="iconfont undefined"></i>
  大数据
</a></li><li class="dropdown-item"><!----> <a href="/categories/后端/" class="nav-link"><i class="iconfont undefined"></i>
  后端
</a></li><li class="dropdown-item"><!----> <a href="/categories/中间件/" class="nav-link"><i class="iconfont undefined"></i>
  中间件
</a></li></ul></div></div><div class="nav-item"><a href="/tag/" class="nav-link"><i class="iconfont reco-tag"></i>
  标签
</a></div><div class="nav-item"><a href="/timeline/" class="nav-link"><i class="iconfont reco-date"></i>
  时间线
</a></div><div class="nav-item"><a href="/about/" class="nav-link"><i class="iconfont reco-message"></i>
  关于我
</a></div> <a href="https://github.com/f1ybird" target="_blank" rel="noopener noreferrer" class="repo-link"><i class="iconfont reco-github"></i>
    GitHub
    <span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></nav></div></header> <div class="sidebar-mask" data-v-0b87bb44></div> <aside class="sidebar" data-v-0b87bb44><div class="personal-info-wrapper" data-v-7e653f02><img src="/vuepress/my-head.png" alt="author-avatar" class="personal-img" data-v-7e653f02> <h3 class="name" data-v-7e653f02>
    flybird
  </h3> <div class="num" data-v-7e653f02><div data-v-7e653f02><h3 data-v-7e653f02>63</h3> <h6 data-v-7e653f02>文章</h6></div> <div data-v-7e653f02><h3 data-v-7e653f02>26</h3> <h6 data-v-7e653f02>标签</h6></div></div> <hr data-v-7e653f02></div> <nav class="nav-links"><div class="nav-item"><a href="/index.html" class="nav-link"><i class="iconfont reco-home"></i>
  主页
</a></div><div class="nav-item"><div class="dropdown-wrapper"><a class="dropdown-title"><span class="title"><i class="iconfont reco-category"></i>
      分类
    </span> <span class="arrow right"></span></a> <ul class="nav-dropdown" style="display:none;"><li class="dropdown-item"><!----> <a href="/categories/大数据/" class="nav-link"><i class="iconfont undefined"></i>
  大数据
</a></li><li class="dropdown-item"><!----> <a href="/categories/后端/" class="nav-link"><i class="iconfont undefined"></i>
  后端
</a></li><li class="dropdown-item"><!----> <a href="/categories/中间件/" class="nav-link"><i class="iconfont undefined"></i>
  中间件
</a></li></ul></div></div><div class="nav-item"><a href="/tag/" class="nav-link"><i class="iconfont reco-tag"></i>
  标签
</a></div><div class="nav-item"><a href="/timeline/" class="nav-link"><i class="iconfont reco-date"></i>
  时间线
</a></div><div class="nav-item"><a href="/about/" class="nav-link"><i class="iconfont reco-message"></i>
  关于我
</a></div> <a href="https://github.com/f1ybird" target="_blank" rel="noopener noreferrer" class="repo-link"><i class="iconfont reco-github"></i>
    GitHub
    <span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></nav>  <ul class="sidebar-links"><li><a href="/views/" aria-current="page" class="sidebar-link">概览</a></li><li><section class="sidebar-group collapsable depth-0"><p class="sidebar-heading"><span>大数据</span> <span class="arrow right"></span></p> <!----></section></li><li><section class="sidebar-group collapsable depth-0"><p class="sidebar-heading"><span>中间件</span> <span class="arrow right"></span></p> <!----></section></li><li><section class="sidebar-group collapsable depth-0"><p class="sidebar-heading"><span>后端</span> <span class="arrow right"></span></p> <!----></section></li></ul> </aside> <div class="password-shadow password-wrapper-in" style="display:none;" data-v-73c95a87 data-v-0b87bb44><h3 class="title" style="display:none;" data-v-73c95a87 data-v-73c95a87>HBase介绍</h3> <!----> <label id="box" class="inputBox" style="display:none;" data-v-73c95a87 data-v-73c95a87><input type="password" value="" data-v-73c95a87> <span data-v-73c95a87>Konck! Knock!</span> <button data-v-73c95a87>OK</button></label> <div class="footer" style="display:none;" data-v-73c95a87 data-v-73c95a87><span data-v-73c95a87><i class="iconfont reco-theme" data-v-73c95a87></i> <a target="blank" href="https://vuepress-theme-reco.recoluan.com" data-v-73c95a87>vuePress-theme-reco</a></span> <span data-v-73c95a87><i class="iconfont reco-copyright" data-v-73c95a87></i> <a data-v-73c95a87><span data-v-73c95a87>flybird</span>
            
          <span data-v-73c95a87>2020 - </span>
          2021
        </a></span></div></div> <div data-v-0b87bb44><main class="page"><!----> <div class="page-title" style="display:none;"><h1>HBase介绍</h1> <hr> <div data-v-7b2e794a><i class="iconfont reco-account" data-v-7b2e794a><span data-v-7b2e794a>flybird</span></i> <i class="iconfont reco-date" data-v-7b2e794a><span data-v-7b2e794a>2021-02-21</span></i> <i class="iconfont reco-eye" data-v-7b2e794a><span id="/views/bigdata/hbase%E4%BB%8B%E7%BB%8D.html" data-flag-title="Your Article Title" class="leancloud-visitors" data-v-7b2e794a><a class="leancloud-visitors-count" style="font-size:.9rem;font-weight:normal;color:#999;"></a></span></i> <i class="iconfont reco-tag tags" data-v-7b2e794a><span class="tag-item" data-v-7b2e794a>
      hbase
    </span></i></div></div> <div class="theme-reco-content content__default" style="display:none;"><h1 id="hbase介绍"><a href="#hbase介绍" class="header-anchor">#</a> HBase介绍</h1> <h3 id="_1、关系型数据库与非关系型数据库"><a href="#_1、关系型数据库与非关系型数据库" class="header-anchor">#</a> 1、关系型数据库与非关系型数据库</h3> <h5 id="_1-关系型数据库"><a href="#_1-关系型数据库" class="header-anchor">#</a> （1）关系型数据库</h5> <p><img src="https://cdn.jsdelivr.net/gh/f1ybird/cloudimg/img/%E5%85%B3%E7%B3%BB%E5%9E%8B%E6%95%B0%E6%8D%AE%E5%BA%93.png" alt=""></p> <p>​				关系型数据库最典型的数据机构是表，由二维表及其之间的联系所组成的一个数据组织</p> <p>​				优点：</p> <p>​						1、易于维护：都是使用表结构，格式一致</p> <p>​						2、使用方便：SQL语言通用，可用于复杂查询</p> <p>​						3、复杂操作：支持SQL，可用于一个表以及多个表之间非常复杂的查询</p> <p>​				缺点：</p> <p>​						1、读写性能比较差，尤其是海量数据的高效率读写</p> <p>​						2、固定的表结构，灵活度稍欠</p> <p>​						3、高并发读写需求，传统关系型数据库，硬盘IO是一个很大的瓶颈</p> <h5 id="_2-非关系型数据库"><a href="#_2-非关系型数据库" class="header-anchor">#</a> （2）非关系型数据库</h5> <p><img src="https://cdn.jsdelivr.net/gh/f1ybird/cloudimg/img/%E9%9D%9E%E5%85%B3%E7%B3%BB%E5%9E%8B%E6%95%B0%E6%8D%AE%E5%BA%93.png" alt=""></p> <p>​				非关系型数据库严格上不是一种数据库，应该是一种数据结构化存储方法的集合，可以是文档或键值对</p> <p>​				优点：</p> <p>​						1、格式灵活：存储数据的格式可以是key，value形式、文档形式、图片形式等等，文档形式、图片形式等等，使用灵活，应用场景广泛，而关系型数据库则只支持基础类型。</p> <p>​						2、速度快：nosql可以使用硬盘或者随机存储器作为载体，而关系型数据库只能使用硬盘</p> <p>​						3、高扩展性</p> <p>​						4、成本低：nosql数据库部署简单，基本都是开源软件</p> <p>​				缺点：</p> <p>​						1、不提供sql支持，学习和使用成本较高；</p> <p>​						2、无事务处理</p> <p>​						3、数据结构相对复杂，复杂查询方面稍欠</p> <h3 id="_2、hbase简介"><a href="#_2、hbase简介" class="header-anchor">#</a> 2、HBase简介</h3> <div class="language- line-numbers-mode"><pre class="language-text"><code>	Use Apache HBase™ when you need random, realtime read/write access to your Big Data. This project's goal is the hosting of very large tables -- billions of rows X millions of columns -- atop clusters of commodity hardware. Apache HBase is an open-source, distributed, versioned, non-relational database modeled after Google's Bigtable: A Distributed Storage System for Structured Data by Chang et al. Just as Bigtable leverages the distributed data storage provided by the Google File System, Apache HBase provides Bigtable-like capabilities on top of Hadoop and HDFS.
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br></div></div><p>​		HBase的全称是Hadoop Database,是一个高可靠性，高性能、面向列、可伸缩、实时读写的分布式数据库。</p> <p>​		利用Hadoop HDFS作为其文件存储系统，利用Hadoop MapReduce来处理HBase中的海量数据，利用Zookeeper作为其分布式协同服务。</p> <p>​		主要用来存储非结构化和半结构化数据的松散数据（列存NoSQL数据库）。</p> <p>​		注意：NoSQL的全称是Not Only SQL，泛指非关系型数据库。</p> <h3 id="_3、hbase数据模型"><a href="#_3、hbase数据模型" class="header-anchor">#</a> 3、HBase数据模型</h3> <p><img src="https://cdn.jsdelivr.net/gh/f1ybird/cloudimg/img/hbase%E6%95%B0%E6%8D%AE%E6%A8%A1%E5%9E%8B.png" alt=""></p> <h5 id="_1-rowkey"><a href="#_1-rowkey" class="header-anchor">#</a> (1)rowkey</h5> <p>​			（1）决定一行数据，每行记录的唯一标识</p> <p>​			（2）按照字典序排序</p> <p>​			（3）RowKey只能存储64K的字节数据</p> <h5 id="_2-column-family-qualifier"><a href="#_2-column-family-qualifier" class="header-anchor">#</a> (2)Column Family &amp; Qualifier</h5> <p>​			（1）HBase表中的每个列都归属于某个列族，列族必须作为表模式(schema)定义的一部分预先给出。如 create ‘test’, ‘course’；</p> <p>​			（2）列名以列族作为前缀，每个“列族”都可以有多个列成员(column)；如course:math, course:english, 新的列族成员（列）可以随后按需、动态加入；</p> <p>​			（3）权限控制、存储以及调优都是在列族层面进行的；</p> <p>​			（4）HBase把同一列族里面的数据存储在同一目录下，由几个文件保存。</p> <h5 id="_3-timestamp时间戳"><a href="#_3-timestamp时间戳" class="header-anchor">#</a> (3)TimeStamp时间戳</h5> <p>​			（1）在HBase每个cell存储单元对同一份数据有多个版本，根据唯一的时间戳来区分每个版本之间的差异，不同版本的数据按照时间倒序排序，最新的数据版本排在最前面。</p> <p>​			（2）时间戳的类型是 64位整型。</p> <p>​			（3）时间戳可以由HBase(在数据写入时自动)赋值，此时间戳是精确到毫秒的当前系统时间。</p> <p>​			（4）时间戳也可以由客户显式赋值，如果应用程序要避免数据版本冲突，就必须自己生成具有唯一性的时间戳。</p> <h5 id="_4-cell"><a href="#_4-cell" class="header-anchor">#</a> (4)Cell</h5> <p>​			（1）由行和列的坐标交叉决定；</p> <p>​			（2）单元格是有版本的；</p> <p>​			（3）单元格的内容是未解析的字节数组；</p> <p>​					1、由{row key， column( =<family> +<qualifier>)， version} 唯一确定的单元。
​					2、cell中的数据是没有类型的，全部是字节数组形式存贮。</qualifier></family></p> <h3 id="_4、hbase架构"><a href="#_4、hbase架构" class="header-anchor">#</a> 4、HBase架构</h3> <p><img src="https://cdn.jsdelivr.net/gh/f1ybird/cloudimg/img/hbase%E6%9E%B6%E6%9E%84%E5%9B%BE.png" alt=""></p> <h4 id="角色介绍"><a href="#角色介绍" class="header-anchor">#</a> 角色介绍</h4> <h5 id="_1-client"><a href="#_1-client" class="header-anchor">#</a> （1）Client</h5> <p>​			1、包含访问HBase的接口并维护cache来加快对HBase的访问。</p> <h5 id="_2-zookeeper"><a href="#_2-zookeeper" class="header-anchor">#</a> （2）Zookeeper</h5> <p>​			1、保证任何时候，集群中只有一个活跃master</p> <p>​			2、存储所有region的寻址入口</p> <p>​			3、实时监控region server的上线和下线信息，并实时通知master</p> <p>​			4、存储HBase的schema和table元数据</p> <h5 id="_3-master"><a href="#_3-master" class="header-anchor">#</a> （3）Master</h5> <p>​			1、为region server分配region</p> <p>​			2、负责region server的负载均衡</p> <p>​			3、发现失效的region server并重新分配其上的region</p> <p>​			4、管理用户对table的增删改操作</p> <h5 id="_4-regionserver"><a href="#_4-regionserver" class="header-anchor">#</a> （4）RegionServer</h5> <p>​			1、region server维护region，处理对这些region的IO请求</p> <p>​			2、region server负责切分在运行过程中变得过大的region</p> <h4 id="regionserver组件介绍"><a href="#regionserver组件介绍" class="header-anchor">#</a> regionserver组件介绍</h4> <h5 id="_1-region"><a href="#_1-region" class="header-anchor">#</a> （1）region</h5> <p>​			1、HBase自动把表水平划分成多个区域(region)，每个region会保存一个表里某段连续的数据</p> <p>​			2、每个表一开始只有一个region，随着数据不断插入表，region不断增大，当增大到一个阈值的时候，region就会等分会两个新的region（裂变）</p> <p>​			3、当table中的行不断增多，就会有越来越多的region。这样一张完整的表被保存在多个Regionserver 上。</p> <h5 id="_2-memstore与storefile"><a href="#_2-memstore与storefile" class="header-anchor">#</a> （2）Memstore与storefile</h5> <p>​			1、一个region由多个store组成，一个store对应一个CF（列族）</p> <p>​			2、store包括位于内存中的memstore和位于磁盘的storefile写操作先写入memstore，当memstore中的数据达到某个阈值，hregionserver会启动flashcache进程写入storefile，每次写入形成单独的一个storefile</p> <p>​			3、当storefile文件的数量增长到一定阈值后，系统会进行合并（minor、major ），在合并过程中会进行版本合并和删除工作（majar），形成更大的storefile</p> <p>​			4、当一个region所有storefile的大小和数量超过一定阈值后，会把当前的region分割为两个，并由hmaster分配到相应的regionserver服务器，实现负载均衡</p> <p>​			5、客户端检索数据，先在memstore找，找不到去blockcache，找不到再找storefile</p> <h4 id="注意问题"><a href="#注意问题" class="header-anchor">#</a> 注意问题：</h4> <p>​			1、HRegion是HBase中分布式存储和负载均衡的最小单元。最小单元就表示不同的HRegion可以分布在不同的 HRegion server上。</p> <p>​			2、HRegion由一个或者多个Store组成，每个store保存一个columns family。</p> <p>​			3、每个Strore又由一个memStore和0至多个StoreFile组成。如图：StoreFile以HFile格式保存在HDFS上。</p> <p><img src="https://cdn.jsdelivr.net/gh/f1ybird/cloudimg/img/hbase%E6%9E%B6%E6%9E%84%E5%9B%BE3.png" alt=""></p> <h3 id="_5、hbase读写流程"><a href="#_5、hbase读写流程" class="header-anchor">#</a> 5、HBase读写流程</h3> <h5 id="_1-读流程"><a href="#_1-读流程" class="header-anchor">#</a> （1）读流程</h5> <p>​		1、客户端从zookeeper中获取meta表所在的regionserver节点信息</p> <p>​		2、客户端访问meta表所在的regionserver节点，获取到region所在的regionserver信息</p> <p>​		3、客户端访问具体的region所在的regionserver，找到对应的region及store</p> <p>​		4、首先从memstore中读取数据，如果读取到了那么直接将数据返回，如果没有，则去blockcache读取数据</p> <p>​		5、如果blockcache中读取到数据，则直接返回数据给客户端，如果读取不到，则遍历storefile文件，查找数据</p> <p>​		6、如果从storefile中读取不到数据，则返回客户端为空，如果读取到数据，那么需要将数据先缓存到blockcache中（方便下一次读取），然后再将数据返回给客户端。</p> <p>​		7、blockcache是内存空间，如果缓存的数据比较多，满了之后会采用LRU策略，将比较老的数据进行删除。</p> <h5 id="_2-写流程"><a href="#_2-写流程" class="header-anchor">#</a> （2）写流程</h5> <p>​		1、客户端从zookeeper中获取meta表所在的regionserver节点信息</p> <p>​		2、客户端访问meta表所在的regionserver节点，获取到region所在的regionserver信息</p> <p>​		3、客户端访问具体的region所在的regionserver，找到对应的region及store</p> <p>​		4、开始写数据，写数据的时候会先想hlog中写一份数据（方便memstore中数据丢失后能够根据hlog恢复数据，向hlog中写数据的时候也是优先写入内存，后台会有一个线程定期异步刷写数据到hdfs，如果hlog的数据也写入失败，那么数据就会发生丢失）</p> <p>​		5、hlog写数据完成之后，会先将数据写入到memstore，memstore默认大小是64M，当memstore满了之后会进行统一的溢写操作，将memstore中的数据持久化到hdfs中，</p> <p>​		6、频繁的溢写会导致产生很多的小文件，因此会进行文件的合并，文件在合并的时候有两种方式，minor和major，minor表示小范围文件的合并，major表示将所有的storefile文件都合并成一个，具体详细的过程，后续会讲解。</p></div> <footer class="page-edit" style="display:none;"><div class="edit-link"><a href="https://github.com/f1ybird/edit/master/docs/views/bigdata/hbase介绍.md" target="_blank" rel="noopener noreferrer">在 GitHub 上编辑此页！</a> <span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></div> <div class="last-updated"><span class="prefix">Last Updated: </span> <span class="time">2021-02-21 18:14:38</span></div></footer> <!----> <!----></main> <!----> <div class="comments-wrapper" data-v-0b87bb44><div class="valine-wrapper"><div id="valine"></div></div></div></div></div></div></div></div><div class="global-ui"><div class="back-to-ceiling" style="right:1rem;bottom:6rem;width:2.5rem;height:2.5rem;border-radius:.25rem;line-height:2.5rem;display:none;" data-v-44bd5a18 data-v-44bd5a18><svg t="1574745035067" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="5404" class="icon" data-v-44bd5a18><path d="M526.60727968 10.90185116a27.675 27.675 0 0 0-29.21455937 0c-131.36607665 82.28402758-218.69155461 228.01873535-218.69155402 394.07834331a462.20625001 462.20625001 0 0 0 5.36959153 69.94390903c1.00431239 6.55289093-0.34802892 13.13561351-3.76865779 18.80351572-32.63518765 54.11355614-51.75690182 118.55860487-51.7569018 187.94566865a371.06718723 371.06718723 0 0 0 11.50484808 91.98906777c6.53300375 25.50556257 41.68394495 28.14064038 52.69160883 4.22606766 17.37162448-37.73630017 42.14135425-72.50938081 72.80769204-103.21549295 2.18761121 3.04276886 4.15646224 6.24463696 6.40373557 9.22774369a1871.4375 1871.4375 0 0 0 140.04691725 5.34970492 1866.36093723 1866.36093723 0 0 0 140.04691723-5.34970492c2.24727335-2.98310674 4.21612437-6.18497483 6.3937923-9.2178004 30.66633723 30.70611158 55.4360664 65.4791928 72.80769147 103.21549355 11.00766384 23.91457269 46.15860503 21.27949489 52.69160879-4.22606768a371.15156223 371.15156223 0 0 0 11.514792-91.99901164c0-69.36717486-19.13165746-133.82216804-51.75690182-187.92578088-3.42062944-5.66790279-4.76302748-12.26056868-3.76865837-18.80351632a462.20625001 462.20625001 0 0 0 5.36959269-69.943909c-0.00994388-166.08943902-87.32547796-311.81420293-218.6915546-394.09823051zM605.93803103 357.87693858a93.93749974 93.93749974 0 1 1-187.89594924 6.1e-7 93.93749974 93.93749974 0 0 1 187.89594924-6.1e-7z" p-id="5405" data-v-44bd5a18></path><path d="M429.50777625 765.63860547C429.50777625 803.39355007 466.44236686 1000.39046097 512.00932183 1000.39046097c45.56695499 0 82.4922232-197.00623328 82.5015456-234.7518555 0-37.75494459-36.9345906-68.35043303-82.4922232-68.34111062-45.57627738-0.00932239-82.52019037 30.59548842-82.51086798 68.34111062z" p-id="5406" data-v-44bd5a18></path></svg></div><!----><div data-v-48108b4c><div class="DetailsOpenFlag" style="right:1rem;bottom:9rem;width:2.5rem;height:2.5rem;border-radius:.25rem;line-height:2.5rem;font-size:14px;font-weight:500;display:none;" data-v-48108b4c>
 展开 

</div></div></div></div>
    <script src="/assets/js/app.55c4f7c3.js" defer></script><script src="/assets/js/5.86109dd2.js" defer></script><script src="/assets/js/1.74974061.js" defer></script><script src="/assets/js/2.ab8aa845.js" defer></script><script src="/assets/js/49.feee5279.js" defer></script><script src="/assets/js/18.cfe435f1.js" defer></script>
  </body>
</html>
